package cn.mooncode.basketballManage.service.impl;

import cn.mooncode.basketballManage.pojo.RespPageBean;
import cn.mooncode.basketballManage.service.ICoachinfoService;
import cn.mooncode.basketballManage.mapper.CoachinfoMapper;
import cn.mooncode.basketballManage.pojo.Coachinfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jwz
 * @since 2021-03-28
 */
@Service
public class CoachinfoServiceImpl extends ServiceImpl<CoachinfoMapper, Coachinfo> implements ICoachinfoService {

    @Autowired
    private CoachinfoMapper coachinfoMapper;

    /**
     * 查看所有教练信息
     * @param currentPage
     * @param size
     * @param coachinfo
     * @return
     */
    @Override
    public RespPageBean getAllCoachInfo(Integer currentPage, Integer size, Coachinfo coachinfo) {
        Page<Coachinfo> page = new Page<>(currentPage, size);
        IPage<Coachinfo> coachinfoIPage = coachinfoMapper.getAllCoachInfo(page, currentPage, size);
        return new RespPageBean(coachinfoIPage.getTotal(), coachinfoIPage.getRecords());
    }

    /**
     * 获取当前教练信息
     * @param id
     * @return
     */
    @Override
    public Coachinfo getCurrentCoach(Integer id) {
        return coachinfoMapper.getCurrentCoach(id);
    }
}
